home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / ge_cool.lha / GE_COOL2.1 / man / oldman3 / Random.3T < prev    next >
Text File  |  1992-06-26  |  4KB  |  116 lines

  1. .TH RANDOM
  2. .SH NAME
  3. Random  A portable, user-selectable random number generator
  4. .SH SYNOPSIS
  5. \f3#include \f1<cool/Random.h>
  6. .SH DESCRIPTION
  7. The Random class provides several general-purpose random number generators 
  8. with features similar to those as described in Chapter 7 of 
  9. \f2Numerical Recipes in C\f1, 
  10. written by William T. \p
  11. Vetterling. The ANSI C draft standard specifies 
  12. the 
  13.  rand 
  14. function that allows an application to obtain successive random numbers in 
  15. a sequence by repeated calls. However, system-supplied random number generators 
  16. in the form of the 
  17.  rand 
  18. function are generally of poor quality, particularly 
  19. when true random distribution over a range is important. Specifically, system 
  20. random number generators are almost always linear congruential generators whose 
  21. period is not very large. The ANSI C draft specification only requires a 
  22. modulus of 32767, which can be disastrous for such uses as a Monte Carlo 
  23. integration over 10^6 points.
  24. .PP
  25. The 
  26.  Random 
  27. class allows an application to select one of five types of random 
  28. number generators based upon the usage requirements. Each generator function 
  29. has different characteristics and all are defined to be of type 
  30.  
  31.  RNG_TYPE . 
  32. The 
  33.  
  34.  SIMPLE 
  35. and 
  36.  
  37.  SHUFFLE
  38. functions use the system \p
  39.  rand 
  40. function, while the
  41.  
  42.  ONE_CONGRUENTIAL, THREE_CONGRUENTIAL, 
  43. and \p
  44.  
  45.  SUBTRACTIVE 
  46. functions are 
  47. self-contained, portable implementations. Following are descriptions of each 
  48. generator function.
  49. .PP
  50. .TP .2i
  51. \(bu
  52. \f3SIMPLE\f1  When speed is the predominant concern, this function uses the 
  53. system-supplied \f3rand\f1 function. Although sequential correlation of successive 
  54. random values is a high probability, this function at least ensures that the 
  55. value's least significant bits are as random as the most significant bits. In 
  56. many system random generator functions, the value's least significant bits are 
  57. often less random than the most significant bits.
  58. .TP
  59. \(bu
  60. \f3SHUFFLE\f1  This function uses the \f3rand\f1 function and a shuffling procedure. 
  61. Random numbers are stored in a buffer and selected randomly to break up 
  62. sequential correlation in the system-supplied function. 
  63. .TP
  64. \(bu
  65. \f3ONE_CONGRUENTIAL\f1  This self-contained function uses one linear congruential 
  66. generator instead of the \f3rand\f1 function to implement a portable random number 
  67. generator. This guarantees no sequential correlation between the random values 
  68. returned. 
  69. .TP
  70. \(bu
  71. \f3THREE_CONGRUENTIAL\f1  This portable function uses three linear congruential 
  72. generators to implement a random number generator whose period is essentially 
  73. infinite and has no sequential correlations. 
  74. .TP
  75. \(bu
  76. \f3SUBTRACTIVE\f1  This function implements a portable random number generator that does not use linear congruential generators, but rather an original 
  77. subtractive member function as suggested in Volume 2 of \f2The Art of Computer 
  78. Programming\f1, written by Donald Knuth.
  79. .SH Base Classes
  80.  
  81. .SH Friend Classes
  82. None
  83. .SH Constructor
  84. .TP
  85. \f3Random (RNG_TYPE \f2r_type\f3, int \f2seed \f1= 1\f3, float \f2lower \f1= 0.0,\f3 float \f2upper \f1= 100.0\f3);\f1
  86. Constructor for a floating-point random number generator that initializes the 
  87. selected random number generator function with the user-supplied \f2seed\f1 value.
  88. .SH Member Functions
  89. .TP
  90.  inline double next ();
  91. Returns the next double floating-point random number within the user-specified 
  92. range.
  93. .TP
  94.  nline int get_seed () const;
  95. Returns the seed value for the currently-selected random number generator. 
  96. .TP
  97. \f3inline void set_rng (RNG_TYPE \f2r_type\f3);\f1
  98. Sets the random number generator function to the type selected by the user and 
  99. reinitializes the state.
  100. .TP
  101. \f3inline void set_seed (int \f2seed\f3);\f1
  102. Sets the seed value for the currently-selected random number generator function 
  103. and reinitilizes the state.
  104. .SH COPYRIGHT
  105.  
  106. Copyright (C) 1991 Texas Instruments Incorporated.
  107.  
  108. Permission is granted to any individual or institution to use, copy, modify,
  109. and distribute this software, provided that this complete copyright and
  110. permission notice is maintained, intact, in all copies and supporting
  111. documentation.
  112.  
  113. Texas Instruments Incorporated provides this software "as is" without
  114. express or implied warranty.
  115.  
  116.